<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"
	import="myauctioneer.dto.Article"
	import="myauctioneer.dto.Bid"
	import="myauctioneer.dao.BidDAO"
%>
<%@ include file="header.jsp"%>

<% Article a = (Article) request.getAttribute("article"); %>

<div id="content">
	<h1>
		<%= a.getBrand() %>
		<%= a.getFamilyLine() %>
		<%= a.getModel() %>
	</h1>
	<p>
		<table>
			<tr>
				<td><strong>family line: </strong><%= a.getFamilyLine() %></td>
			</tr>
			<tr>
				<td><strong>model: </strong><%= a.getModel() %></td>
			</tr>
			<tr>
				<td><strong>condition: </strong><%= a.getCondition() %></td>
			</tr>
			<tr>
				<td><strong>valid until: </strong><%= a.getValidUntil() %></td>
			</tr>
			<tr>
				<td><strong>category: </strong><%= a.getCategory() %></td>
			</tr>
			<tr>
				<td><strong>price: </strong><%= a.getPrice() %> €</td>
			</tr>
			<tr>
				<td><strong>sale type: </strong><%= a.getSaleType() %></td>
			</tr>
		</table>
	</p>
	<p>
		<strong>description: </strong>
		<%= a.getDescription() %>
	</p>

	<% java.util.ArrayList<Bid> bids =
		(new BidDAO()).loadBidByArticleId(a.getArticleId()); %>

	<h2>bids:</h2><p>
	<table>
		<tr>
			<th scope="col">user</th>
			<th scope="col">amount</th>
			<th scope="col">time</th>
		</tr><%

		for(Bid b : bids) { %>
			<tr><td>User <%= b.getUserId() %></td>
				<td><%= b.getAmount() %> €</td>
				<td><%= b.getTime() %></td></tr>
		<%
		}
	%></table></p>

<% if(a.isValid()) { %>
	<p>
	<form action="<%= App.getBaseUrl() %>/sales/bidBuy" method="post">
		<input type="hidden" name="id" value="<%= a.getArticleId() %>" />
		<% if(a.getSaleType().equals("directSale")) { %>
		<input type="submit" value="Buy" />
		<% } else { %>
		<input type="text" name="amount" />
		<input type="submit" value="Bid" />
		<% } %>
	</form>
	</p>
<% } %>

	<p class="entry_bottom">
	<span>created by <a href="<%= App.getBaseUrl() %>/user/profile?id=<%= a.getUserId() %>">
			User <%= a.getUserId() %></a>&nbsp;|&nbsp;valid
			until <%= a.getValidUntil() %>
		</span>
	</p>
</div>

<%@ include file="footer.jsp"%>



